CC=gcc
CCX=g++
FLAGS=-W -Wall -g -std=c99 -DWITH_PTHREADS
FLAGSCPP=-W -Wall -g
#FLAGS_LIB=-nostartfiles --shared -fPIC -g -ldl #-rdynamic
FLAGS_LIB= --shared -fPIC -O3 -ldl   #-rdynamic -g
LIB=libs/libInterposer.so
LIBCPP=libs/libInterposerCpp.so
LIBSEQ=libs/libInterposerCppSeq.so
INCLUDE=-I include/ -I ipc/ -I compressors/
DYN_L=-rdynamic -ldl 
HEADERS=include/*
SRC=loggers/LoggerFactory.cpp loggers/XmlLogger.cpp src/log-malloc.c src/log-malloc.cpp src/back_trace.cpp src/DumperFactory.cpp loggers/BinaryStandardFormatLogger.cpp ipc/ipc.h compressors/CompressorProcess.cpp ipc/MESSAGE_QUEUE.cpp stack_trace/stack_trace.cpp ipc/Pipe.cpp ipc/MESSAGE_QUEUE.h

all:$(LIB) $(LIBCPP) $(LIBSEQ)

$(LIB):$(SRC)
	@printf "\033[34;1m\nCompilation de la version minimale de la lib interposer.\n\033[m"
	$(CC) $(INCLUDE) $(FLAGS) $(FLAGS_LIB) -o $(LIB) src/log-malloc.c #src/back_trace.cpp loggers/LoggerFactory.cpp loggers/XmlLogger.cpp

$(LIBCPP):$(SRC)
	@printf "\033[34;1m\nCompilation de la version evoluée de la lib interposer => prise en charge de loggeurs en multithread.\n\033[m"
	$(CXX) $(INCLUDE) $(FLAGSCPP) -DWITH_PTHREADS $(FLAGS_LIB) -lpthread -o $(LIBCPP)  src/log-malloc.cpp loggers/LoggerFactory.cpp loggers/XmlLogger.cpp loggers/BinaryStandardFormatLogger.cpp ipc/MESSAGE_QUEUE.cpp stack_trace/stack_trace.cpp ipc/Pipe.cpp


$(LIBSEQ):$(SRC)
	@printf "\033[34;1m\nCompilation de la version evoluée de la lib interposer => prise en charge de loggeurs sequentiel et de backtraces.\n\033[m"
	$(CXX) $(INCLUDE) $(FLAGSCPP) $(FLAGS_LIB) -o $(LIBSEQ)  src/log-malloc.cpp loggers/LoggerFactory.cpp loggers/XmlLogger.cpp loggers/BinaryStandardFormatLogger.cpp ipc/MESSAGE_QUEUE.cpp stack_trace/stack_trace.cpp ipc/Pipe.cpp


install:
	@printf "\033[34;1m\nDéplacement des libs dans les dossiers libs.\n\033[m"
	cp $(LIB) lib/
	mv $(LIB) ../../samples/proba_dist/bin/libs/

clean:
	@printf "\033[34;1m\nCleaning.\n\033[m"
	rm -rf $(BIN) $(LIB) $(LIBCPP) $(LIBCPP) $(LIBSEQ)  *~ *.o 
	rm *\#\
	rm -rf doc/* *.bsf
	rm -rf memoryTraceProfile*

documentation:$(HEADERS)
	@printf "\033[34;1m\nGénération de la documentation.\n\033[m"	
	doxygen Doxyfile
